'use strict';
const db = uniCloud.database();
const roomsCollection = db.collection('rooms');

exports.main = async (event, context) => {
	const { room_id } = event;
	
	// 参数校验
	if (!room_id) {
		return {
			code: 1,
			message: '缺少房间ID参数'
		};
	}
	
	// 获取房间详情
	const roomInfo = await roomsCollection.doc(room_id).get();
	
	if (!roomInfo.data || roomInfo.data.length === 0) {
		return {
			code: 2,
			message: '房间不存在'
		};
	}
	
	return {
		code: 0,
		message: '获取房间详情成功',
		data: roomInfo.data[0]
	};
}; 